#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

int main()
{
    close(1);
    umask(0000);
    int fd = open("log.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if(fd < 0)
    {
        perror("open fail");
        exit(-1);
    }

    printf("p->fd = %d\n", fd);
    fprintf(stdout, "f->fd = %d\n", fd);
    //fflush(stdout);

    //close(fd);
    fclose(stdout);
    return 0;
}
